<?php

namespace liketp\console;

use liketp\Request;

class CommandRequest extends Request
{
    protected $command = '';
    protected $argv = [];

    public function init()
    {
        $this->server = $_SERVER;
    }

    public function setArgv(array $argv = [])
    {
        if (count($argv) > 0 && preg_match('/^[a-z\$].*/i', $argv[0])) {
            $this->command = array_shift($argv);
        }
        $this->argv = $argv;
    }

    public function command()
    {
        return $this->command ?: 'help';
    }

    public function argv()
    {
        return $this->argv;
    }
}
